package com.sc.nft.controller;
import com.sc.nft.annotation.UserLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.entity.WxMiniUserInfo;
import com.sc.nft.feign.WxMiniPopUpClient;
import com.sc.nft.pool.UserPool;
import com.sc.nft.req.popup.PopUpReq;
import com.sc.nft.req.popup.PopUpWebGetReq;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.popup.PopUpDetailsVO;
import com.sc.nft.vo.popup.PopUpWebGetVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/ipMall/wxMiniMall/user/popUp")
@Api(tags = "用户端小程序弹窗")
public class WxMiniPopUpController {

    private final WxMiniPopUpClient wxMiniPopUpService;



    /**
     * 前台获取小程序弹窗
     * @param request
     * @return
     */
    @PostMapping(value = "/webGet", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "小程序弹窗详情")
    @UserLogin
    public Result<List<PopUpWebGetVO>> webGet(@Valid @RequestBody PopUpWebGetReq request) {
        WxMiniUserInfo wxUser = UserPool.getWxMiniUser();
        request.setMiniUserId(wxUser.getId());
        return wxMiniPopUpService.webGet(request);
    }


}